#!/bin/sh

echo game_set_id:$1

set_time=$(date +%s)
#echo set_time:$set_time

DBA="mysql -uroot -pqy22players -h192.168.1.140 -e"
$DBA"select gmip,gmport from yt_gm.server_list where svr_id=$1;"|grep -v '|'|grep -v ip>gm.txt

gmip=$(awk '{print $1}' gm.txt)
gmport=$(awk '{print $2}' gm.txt)
#echo gmip:$gmip
#echo gmport:$gmport

src_string='cuttle=8100&game_set_id='$1'&parm0=0'
#echo src_string:$src_string

md5_string=`echo -n "${src_string}b105db8f4c1d3e34b0de3a0195a1c70b"|md5sum|cut -d " " -f1`
#echo md5_string:$md5_string

gm_url=$gmip:$gmport

curl -X POST -s -d "$src_string&sign=$md5_string" 'http://'$gm_url

sleep 5
echo 'sleep 5'

#cuttle=8099&game_set_id=55&parm0=1703139240|&parm1=1&sign=47bd5dcd22915d6ebc0545e675b09eae.

src_string='cuttle=8099&game_set_id='$1'&parm0='$set_time'|&parm1=1'
#echo src_string:$src_string

md5_string=`echo -n "${src_string}b105db8f4c1d3e34b0de3a0195a1c70b"|md5sum|cut -d " " -f1`
#echo md5_string:$md5_string

curl -X POST -s -d "$src_string&sign=$md5_string" 'http://'$gm_url

rm -f gm.txt